#ifndef MISC_COMMAND_H_
#define MISC_COMMAND_H_

#include "command.h"

#ifdef _WIN32
#pragma warning( push )
#pragma warning( disable : 4200 )
#endif

#pragma pack(1)
namespace Cmd
{
        enum //CMD_MIS
        {
                SCMD_MISC_NULL                          = 0x0000,
                SCMD_MISC_MASK_WORD_LIST_REQ            = 0x0001,       // 拉取屏蔽脏字列表请求
                SCMD_MISC_MASK_WORD_LIST_RES            = 0x0002,       // 拉取屏蔽脏字列表回应
                SCMD_MISC_CLIENT_REPORT_PARAMETER_REQ   = 0x0003,       // 未使用
                SCMD_MISC_CLIENT_REPORT_PARAMETER_RES   = 0x0004,       // 未使用
                SCMD_MISC_FUNCTION_NOT_SUPPORT_NOTIFY   = 0x0005,       // 不支持提示
                SCMD_MISC_ARS_CONFIGURATION_REQ         = 0x0006,       // 请求自动寻路配置信息
                SCMD_MISC_ARS_CONFIGURATION_RET         = 0x0007,       // 返回自动需路配置信息
        };

        struct stMiscMaskWordListReq:
                t_NullCmd
        {
                stMiscMaskWordListReq():
                        t_NullCmd(CMD_MISC, SCMD_MISC_MASK_WORD_LIST_REQ)
                {
                }
        };
        struct stMiscMaskWordListRes:
                t_NullCmd
        {
                stMiscMaskWordListRes():
                        t_NullCmd(CMD_MISC, SCMD_MISC_MASK_WORD_LIST_RES)
                {
                        finish_ = 0;
                        len_ = 0;
                }
                DWORD getSize() 
                {
                        return sizeof(*this)+len_*sizeof(list_[0]);
                }
                void setListStr(const std::string &str) 
                {
                        strncpy(list_, str.c_str(), str.size());
                }
                BYTE finish_;   //0-no, 1-yes
                WORD len_;
                char list_[0];  //Json格式
                /*
                 * {
                 *      "maskwords":
                 *      [
                 *              "word1",
                 *              "word2",
                 *              ...
                 *      ]
                 * }
                 * */
        };
        struct stMiscClientReportParameterReq
                : t_NullCmd
        {
                stMiscClientReportParameterReq()
                        : t_NullCmd(CMD_MISC, SCMD_MISC_CLIENT_REPORT_PARAMETER_REQ)
                {
                }
        };
        struct stMiscClientReportParameterRes
                : t_NullCmd
        {
                stMiscClientReportParameterRes()
                        : t_NullCmd(CMD_MISC, SCMD_MISC_CLIENT_REPORT_PARAMETER_RES)
                {
                        size_ = 0;
                }

                DWORD getSize() const
                {
                        return sizeof(*this) + size_*sizeof(json_[0]);
                }

                WORD size_;
                char json_[0];
                // json = si(uint) + sp(uint) + nlt(unit) + lrt(unit)
        };
        struct stMiscFunctionNotSupportNotify:
                t_NullCmd
        {
                stMiscFunctionNotSupportNotify():
                        t_NullCmd(CMD_MISC, SCMD_MISC_FUNCTION_NOT_SUPPORT_NOTIFY)
                {
                        user_id_ = 0;
                        function_id_ = 0;
                        extra_ = 4294967295;
                        size_ = 0;
                }

                const uint16_t getSize() const
                {
                        return sizeof(*this) + size_*sizeof(msg_box_[0]);
                }

                uint32_t user_id_;              // 不支持用户id
                uint32_t function_id_;          // 不支持功能id (cmd[16bit] + para[16bit])
                uint32_t extra_;                // 辅助信息: 4294967295(-1)表示无信息
                uint16_t size_;
                char msg_box_[0];
        };
        struct stMiscArsConfigurationReq:
                t_NullCmd
        {
                stMiscArsConfigurationReq():
                        t_NullCmd(CMD_MISC, SCMD_MISC_ARS_CONFIGURATION_REQ)
                {
                }
        };
        struct stMiscArsConfigurationRet:
                t_NullCmd
        {
                stMiscArsConfigurationRet():
                        t_NullCmd(CMD_MISC, SCMD_MISC_ARS_CONFIGURATION_RET)
                {
                }

                uint32_t getSize() const
                {
                        return sizeof(*this) + size_*sizeof(json_[0]);
                }

                uint16_t size_;
                char json_[0];
                // json = switch(bool) + timeout(uint) + threshold(uint) + pack_num(uint) + pack_it(uint) + ng_delay(uint) + ng_plr(uint) + bad_delay(uint) + bad_plr(uint)
        };
};      // namespace Cmd
#pragma pack()

#ifdef _WIN32
#pragma warning( pop )
#endif

#endif //MISC_COMMAND_H_
